<template>
	<el-container>
		<el-header style="height: auto;">
			<sc-select-filter :data="filterData" :label-width="80" @on-change="filterChange"></sc-select-filter>
		</el-header>
		<el-header>
			<div class="left-panel">
			</div>
			<div class="left-panel"> </div>
			<div class="right-panel">
				<div class="right-panel-search">
					<el-input v-model="search.keyword" placeholder="合同名称、编号" clearable></el-input>
					<el-button type="primary" icon="el-icon-search" @click="upsearch"></el-button>
				</div>
			</div>
		</el-header>
		<el-main class="nopadding">
			<scTable ref="table" :apiObj="apiObj" row-key="recordId" stripe remoteSort remoteFilter>
				<el-table-column label="#" type="index" width="50"></el-table-column>
				<el-table-column label="借阅标题" prop="htTitle" width="200"></el-table-column>
				<el-table-column label="关联流程" prop="flowTitle" width="200"></el-table-column>
				<el-table-column label="档案标题" prop="archivesName" width="150"></el-table-column>
				<el-table-column label="是否出库" prop="toOut" width="100">
					<template #default="scope">
						<el-button type="primary" size="small" v-if="scope.row.toOut==='0'">不出库</el-button>
						<el-button type="success" size="small" v-else-if="scope.row.toOut==='1'">出库</el-button>
					</template>
				</el-table-column>
				<el-table-column label="借阅状态" prop="status" width="150">
					<template #default="scope">
						<el-button type="primary" size="small" v-if="scope.row.status==='0'">审批中</el-button>
						<el-button type="success" size="small" v-else-if="scope.row.status==='1'">通过</el-button>
						<el-button type="danger" size="small" v-else-if="scope.row.status==='2'">未通过</el-button>
					</template>
				</el-table-column>
				<el-table-column label="开始时间" prop="beginTime" width="150"></el-table-column>
				<el-table-column label="到期时间" prop="endTime" width="150"></el-table-column>
				<el-table-column label="备注" prop="remark" width="300" :show-overflow-tooltip="true"></el-table-column>
				<el-table-column label="操作" fixed="right" align="right" width="100">
					<template #default="scope">
						<el-button-group v-if="scope.row.status=='1'">
							<el-button text type="primary" size="small" @click="table_show(scope.row, scope.$index)">流程</el-button>
						</el-button-group>
					</template>
				</el-table-column>
			</scTable>
		</el-main>
	</el-container>
</template>

<script>
import scSelectFilter from '@/components/scSelectFilter'
export default {
	name: 'My Borrowing Manage',
	components: {
		scSelectFilter,
	},
	data() {
		return {
			dialog: {
				save: false,
				detailsSave:false,
			},
			filterData: [
				{
					title: "申请时间",
					key: "date",
					multiple: false,
					options: [
						{
							label: "全部",
							value: ""
						},
						{
							label: "今日",
							value: "1"
						},
						{
							label: "昨日",
							value: "2"
						},
						{
							label: "一周内",
							value: "3"
						},
						{
							label: "一月内",
							value: "4"
						},
						{
							label: "一月前",
							value: "5"
						}
					]
				},
				{
					title: "借阅状态",
					key: "status",
					multiple: false,
					options:[{
						label: "全部",
						value: ""
					},{
						label: "审批中",
						value: "0"
					}, {
						label: "已通过",
						value: "1"
					},]
				},
				{
					title: "是否外借",
					key: "toOut",
					multiple: false,
					options:[{
						label: "全部",
						value: ""
					},{
						label: "不出库",
						value: "0"
					}, {
						label: "出库",
						value: "1"
					},]
				}
			],

			apiObj: this.$API.archives.archivesBorrowing.getArchivesBorrowingList,
			selection: [],
			search: {
				date:'',
				status:'',
				toOut:'',
				keyword:'',
			}
		}
	},
	mounted() {
	},
	methods: {
		filterChange(data){
			this.search.date = data.date;
			this.search.status = data.status;
			this.search.toOut = data.toOut;
			this.$refs.table.upData(this.search)
		},
		//查看
		table_show(row) {
			this.$nextTick(() => {
				this.$router.replace({
					path: '/bpm/handle/read',
					query: {
						runId: row.runId
					}
				})
			})
		},
		//搜索
		async upsearch() {
			this.$refs.table.upData(this.search)
		},
		//本地更新数据
		handleSaveSuccess() {
			this.$refs.table.refresh()
		}
	}
}
</script>

<style>
</style>
